layui.use(['jquery', 'table', 'layer'], function() {
	var $ = layui.jquery;
	var table = layui.table;
	var layer = layui.layer;

	table.init('table', {
		limit: 100
	});
	table.on('edit(table)', function(obj) {
		var value = obj.value;
		var data = obj.data;
		var field = obj.field;
		$.getJSON('save', {
			attackerId: data.id,
			defenderId: field,
			damage: value
		}, function(result, textStatus, req) {
			if (result.state == 'ok') {
				// 成功
				layer.msg(result.msg, {
					icon: 6
				});
			} else {
				// 失败
				layer.msg(result.msg, {
					icon: 5,
					anim: 6
				});
			}
		})
	});
});